'''
Created on 2011-04-09

@author: kacper
'''
from parsing.parser import sents_parse
import sys
from config.config import testPath, savePath, getValidParseExamplesList,\
    getInvalidParseExamplesList
import os


def tryParseValid():
    validKbPaths =  getValidParseExamplesList();
    validKBs = map(sents_parse,validKbPaths)
    
def tryParseInvalid():
    invalidKbPaths =  getInvalidParseExamplesList();
    invalidKBs = map(sents_parse,invalidKbPaths)
    
        
def trySaveProg((pathToFile, KB)):    
    f = open(pathToFile)
    for formula in KB:
        f.write(formula.prt() + "\n")
            

def trySaveProgs():
    validKbPaths =  getValidParseExamplesList();
    validKBs = map(sents_parse(),validKbPaths)
    
    savePaths = zip(
            map(lambda x : x+ "save",validKbPaths),
            validKBs )
    
    map(trySaveProg, savePaths)

if __name__ == '__main__':
    tryParseValid()
    tryParseInvalid()   
